<template>
    <div class="banner-container">
        <!-- bfc banner 位置 -->
        <div class="banner" 
            v-on:click="handleBannerClick">
            <img class="banner-img" 
                v-bind:src="bannerImg" />
            <div class="banner-info">
                <div class="banner-tittle">
                    {{this.sightName}}
                </div>
                <div class="banner-number">
                    <span class="iconfont banner-icon">&#xe692;</span>
                    {{this.gallaryImgs.length}}
                </div>
            </div>    
        </div>
        <!-- vue动画过于扯淡，我之前测试过多次，有时候直接用dom操作解决 -->
        <fade-animation>
            <common-gallary 
                v-bind:imgs="gallaryImgs" 
                v-show="showGallary"
                v-on:close="handleGallaryClose"
                />
        </fade-animation>
    </div>
</template>


<script type="text/javascript">
    import CommonGallary from '../commons/gallary/Gallary.vue'     
    import FadeAnimation from '../commons/fade-animation/FadeAnimation'

	export default{
		name:"banner",
        props:{
            sightName: String,
            bannerImg: String,
            gallaryImgs: Array 
        },
		data(){
			return {
				showGallary: false
			}
		},
        components:{
            CommonGallary,
            FadeAnimation
        },
        methods:{
            handleBannerClick(){          //显示gallary
                this.showGallary = true
            },
            handleGallaryClose () {       //隐藏gallary
                this.showGallary = false
            }
        },
        mounted(){
            //console.log(this.bannerImg);          //空
        },
        updated(){
            //console.log(this.gallaryImgs);          //这个方法会被执行，但是我这里服务端响应没搞好，这个过程不免关系
        }
	}
</script>

<style lang="stylus" scoped>
  .banner
    position: relative
    overflow: hidden
    height: 0
    padding-bottom: 55%               /* 撑开区域防止页面抖动 */
    .banner-img
      width: 100%
    .banner-info
      display: flex
      position: absolute
      left: 0
      right: 0
      bottom: 0
      line-height: .6rem
      color: #fff
      background-image: linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.8))       /* 背景色渐变效果 */
      .banner-tittle
        flex: 1
        font-size: .32rem
        padding: 0 .2rem
      .banner-number
        height: .32rem
        line-height: .32rem
        margin-top: .14rem
        padding: 0 .4rem
        border-radius: .2rem
        background: rgba(0, 0, 0, .8)
        font-size: .24rem
        .banner-icon
          font-size: .24rem
</style>
